package com.belizer.demo.thread;

import java.util.concurrent.TimeUnit;

public class Demo2 {

    public static void main(String[] args) throws InterruptedException {
        final Task task = new Task();


        //一个线程过来先设置了countdownlatch
        task.setCountDownLatch(1);

        //另一个线程设置countdownlatch
        new Thread(()->{
            task.setCountDownLatch(2);
        }).start();

        //保证另一个线程执行完成
        TimeUnit.SECONDS.sleep(2);

        System.out.println(task.getCountDownLatch().getCount());
    }


}
